package com.ruoyi.tsjData.service.impl;

import java.util.List;
import java.util.concurrent.Future;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.calculate.BezierCurveUtil;
import com.ruoyi.tsjData.domain.plat.DataTshjJx;
import com.ruoyi.tsjData.mapper.DataTshjJxMapper;
import com.ruoyi.tsjData.service.IDataTshjJxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;


/**
 * 提升机-间隙测试Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-10-25
 */
@Service
public class DataTshjJxServiceImpl implements IDataTshjJxService
{
    @Autowired(required = false)
    private DataTshjJxMapper dataTshjJxMapper;

    /**
     * 查询提升机-间隙测试
     * 
     * @param jxId 提升机-间隙测试主键
     * @return 提升机-间隙测试
     */
    @Override
    public DataTshjJx selectDataTshjJxByJxId(Long jxId)
    {
        return dataTshjJxMapper.selectDataTshjJxByJxId(jxId);
    }

    /**
     * 间隙测试
     * @param dataTaskId 任务id
     * @return
     */
    @Override
    @Async("threadPoolKy")
    public Future<List<DataTshjJx>> selectJx(Long dataTaskId) {
        List<DataTshjJx> dataTshjJxEntityList = dataTshjJxMapper.selectDataTshjJxByDataTaskId(dataTaskId);
        if (dataTshjJxEntityList.size() != 0) {
            dataTshjJxEntityList.forEach(item -> {
                item.setWyLeftChartLineDTO(BezierCurveUtil.calPoints(item.getWyLeftList(), 0.1f, true));
                item.setWyRightChartLineDTO(BezierCurveUtil.calPoints(item.getWyRightList(), 0.1f, true));
            });
        }
        return new AsyncResult<>(dataTshjJxEntityList);
    }


    /**
     * 查询提升机-间隙测试
     *
     * @param dataTaskId 提升机-间隙测试任务id
     * @return 提升机-间隙测试
     */
    @Override
    public List<DataTshjJx> selectDataTshjJxByDataTaskId(Long dataTaskId) {
        return dataTshjJxMapper.selectDataTshjJxByDataTaskId(dataTaskId);
    }

    /**
     * 查询提升机-间隙测试列表
     * 
     * @param dataTshjJx 提升机-间隙测试
     * @return 提升机-间隙测试
     */
    @Override
    public List<DataTshjJx> selectDataTshjJxList(DataTshjJx dataTshjJx)
    {
        return dataTshjJxMapper.selectDataTshjJxList(dataTshjJx);
    }

    /**
     * 新增提升机-间隙测试
     * 
     * @param dataTshjJx 提升机-间隙测试
     * @return 结果
     */
    @Override
    public int insertDataTshjJx(DataTshjJx dataTshjJx)
    {
        dataTshjJx.setCreateTime(DateUtils.getNowDate());
        return dataTshjJxMapper.insertDataTshjJx(dataTshjJx);
    }

    /**
     * 批量新增间隙数据
     * @param dataTshjJxs 提升机-间隙测试
     * @return
     */
    @Override
    public int batchDataTshjJx(List<DataTshjJx> dataTshjJxs) {
        return dataTshjJxMapper.batchDataTshjJx(dataTshjJxs);
    }

    /**
     * 修改提升机-间隙测试
     * 
     * @param dataTshjJx 提升机-间隙测试
     * @return 结果
     */
    @Override
    public int updateDataTshjJx(DataTshjJx dataTshjJx)
    {
        dataTshjJx.setUpdateTime(DateUtils.getNowDate());
        return dataTshjJxMapper.updateDataTshjJx(dataTshjJx);
    }

    /**
     * 批量修改提升机-间隙测试
     * @param dataTshjJxs 提升机-间隙测试
     * @return
     */
    @Override
    public int updateBatchDataTshjJx(List<DataTshjJx> dataTshjJxs) {
        return dataTshjJxMapper.batchDataTshjJx(dataTshjJxs);
    }

    /**
     * 变更间隙测试任务状态
     * @param dataTaskIds 间隙测试任务id
     * @return
     */
    @Override
    public int updateDataTshjJxByDataTaskIds(Long[] dataTaskIds) {
        return dataTshjJxMapper.updateDataTshjJxByDataTaskIds(dataTaskIds);
    }

    /**
     * 变更间隙测试任务状态为2
     * @param dataTaskId
     * @param jxId
     * @return
     */
    @Override
    public int updateDataTshjJxByJxId(Long dataTaskId, Long jxId) {
        return dataTshjJxMapper.updateDataTshjJxByJxId(dataTaskId, jxId);
    }

    /**
     * 批量删除提升机-间隙测试
     * 
     * @param jxIds 需要删除的提升机-间隙测试主键
     * @return 结果
     */
    @Override
    public int deleteDataTshjJxByJxIds(Long[] jxIds)
    {
        return dataTshjJxMapper.deleteDataTshjJxByJxIds(jxIds);
    }

    /**
     * 删除提升机-间隙测试信息
     * 
     * @param jxId 提升机-间隙测试主键
     * @return 结果
     */
    @Override
    public int deleteDataTshjJxByJxId(Long jxId)
    {
        return dataTshjJxMapper.deleteDataTshjJxByJxId(jxId);
    }
}
